package demo.jmockit;

import mockit.Mock;
import mockit.MockUp;
import org.junit.Assert;
import org.junit.Test;

public class CascadingMockTest {
    @Test
    public void testMethodA() {
        DemoA demoA = new MockUp<DemoA>() {
            @Mock
            public DemoB getB() {
                return new DemoBMock().getMockInstance();
            }
        }.getMockInstance();
        Assert.assertEquals(123, demoA.methodA());
    }
}

class DemoBMock extends MockUp<DemoB> {
    @Mock
    public int methodB() {
        return 123;
    }
}
